<?PHP
function encodeerSimple($text){
	
		$text = strrev($text);
		$aantal = strlen($text);
		$aantal = $aantal / 2;
		
		 if($text[2] == strtolower($text[2])){
			$text[2] = strtoupper($text[2]);
		 }else{
			$text[2] = strtolower($text[2]);
		 }

		if($aantal&1){
			$tekst = $text;
			$nummer = strlen($text);
			$nummer = $nummer / 2;
			$begin = substr($tekst, 0, $nummer);
			$tekst = substr($tekst, $nummer);
			$text = $begin.'#'.$tekst;
		}else{
			$text = $text;
		}
		
		
		return $text;



}

function decodeerSimple($text){

	$nummer = strlen($text);
		 if($text[2] == strtoupper($text[2])){
			$text[2] = strtolower($text[2]);
		 }else{
			$text[2] = strtoupper($text[2]);
		 }
	$text = str_replace("#","",$text);
	return strrev($text);
}

if(isset($_POST['coderen'])){
	$value = encodeerSimple($_POST['input']);
	$input = '<input type="submit" name="decoderen" value="decoderen"/> ';
}
if(isset($_POST['decoderen'])){
	$value = decodeerSimple($_POST['input']);

}
	echo'<form action="function.php" method="post"> 
			<input type="text" name="input" value="'.$value.'"> 
			<input type="submit" name="coderen" value="coderen"/>
			 '.$input.'
		</fom>';

?>